#coding=utf-8
import re
from flask import jsonify,make_response
from  webserver.services.dealwith import dealhistorydata
class GetHisData():
    def __init__(self):
        pass
    def gethistory(self):
        with open("/root/xiao/project/excelword/rundata/rundata.log", 'r', encoding='utf-8') as  f:
            data = f.read()  # str
        try:
            hisresdict = dealhistorydata(data)
            data = {
                "code":0,
                "data":{
                    "count":len(hisresdict),
                    "records":hisresdict
                }
            }
            response = make_response(jsonify(data))
            response.headers['Access-Control-Allow-Origin'] = "*"
            return response
        except:
            data = {
                "code":1,
                "message":"接口响应异常"
            }
            response = make_response(jsonify(data))
            response.headers['Access-Control-Allow-Origin'] = "*"
            return response
            return jsonify(data)
if __name__=="__main__":
    GetHisData().gethistory()
